package com.wy.ifly;

import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.View;
import android.widget.ScrollView;
import android.widget.TextView;

import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {


    private ScrollView scrollView;
    private TextView tv1;

    @RequiresApi(api = Build.VERSION_CODES.M)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        scrollView = findViewById(R.id.scrollView);
        tv1 = findViewById(R.id.tv1);

        //滚动监听
        scrollView.setOnScrollChangeListener(new View.OnScrollChangeListener() {
            @Override
            public void onScrollChange(View view, int x, int y, int oldx, int oldy) {
                Log.i("MyTest", "x:" + x + " ,y:" + y + " ,oldx:" + oldx + " ,oldy:" + oldy);

            }
        });

    }

    /**
     * 页面聚焦改变
     *
     * @param hasFocus 是否有焦点
     */
    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
        if (hasFocus) {
            Display display = getWindowManager().getDefaultDisplay();
            int displayHeight = display.getHeight();
            Log.i("MyTest", "displayHeight:" + displayHeight);
            int height = tv1.getHeight();
            Log.i("MyTest", "tv1 height:" + height);


            int i = displayHeight % height;

        }
    }

}